﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using JigLibX.Collision;
using JigLibX.Physics;
using JigLibX.Geometry;
using JigLibX.Math;

namespace DARE
{
    public class CPhysicSphere : APhysicObject
    {

    #region fields

        private float m_diameter;

    #endregion

    #region properties

        public float Diameter { get { return m_diameter; } }

    #endregion

    #region ctor

        public CPhysicSphere()
        {
            Initialize(1);
        }

        public CPhysicSphere(float diameter)
        {
            Initialize(diameter);
        }

        private void Initialize(float diameter)
        {
            m_diameter = diameter;

            m_body = new Body();
            m_collisionSkin = new CollisionSkin(m_body);
            
            m_collisionSkin.AddPrimitive(new Sphere(Vector3.Zero, diameter / 2.0f), 
                new MaterialProperties(0.5f, 0.7f, 0.6f));
            m_body.CollisionSkin = m_collisionSkin;

            Vector3 com = SetMass(1.0f);
            m_body.EnableBody();

            m_basicModel = new CSphereModel("mSphere", diameter);
        }

        public override APhysicObject Clone()
        {
            CPhysicSphere clone = new CPhysicSphere(m_diameter);

            base.CopyPropertiesTo(clone);
            return clone;
        }

    #endregion

    }
}
